/**
 * 
 */
package org.beanstech.dao;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.beanstech.dao.service.AbstractDao;
import org.beanstech.model.SystemModel;
import org.beanstech.persistence.Mstblcity;
import org.beanstech.persistence.Mstblcondition;
import org.beanstech.persistence.Mstblcountry;
import org.beanstech.persistence.Mstblcourse;
import org.beanstech.persistence.Mstbledition;
import org.beanstech.persistence.Mstblinstitution;
import org.beanstech.persistence.Mstbllocality;
import org.beanstech.persistence.Mstblmembertype;
import org.beanstech.persistence.Mstblstate;
import org.beanstech.persistence.Mstblstudytype;
import org.beanstech.persistence.Mstblsubject;
import org.beanstech.persistence.Mstbluniversity;
import org.beanstech.util.StaticHibernateUtil;

/**
 * @author Bhavin
 *
 */
public class DropDownConstructDao extends AbstractDao{
	
	public DropDownConstructDao() {
		try {
			StaticHibernateUtil.initialize();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public List<SystemModel> getUniversitiesList(){
		
		List<SystemModel> univerisities = new ArrayList<SystemModel>();
		try{
			List queryresult = executeHqlQuery("from Mstbluniversity");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstbluniversity uni = (Mstbluniversity)i.next();
				SystemModel university = new SystemModel();
				university.setId(uni.getIntuniversityid());
				university.setName(uni.getStruniversityname());
				univerisities.add(university);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return univerisities;
	}
	
	public List<SystemModel> getCountryList(){
		
		List<SystemModel> countrylist = new ArrayList<SystemModel>();
		try{
			
			
			List queryresult = executeHqlQuery("from Mstblcountry");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblcountry countries = (Mstblcountry)i.next();
				SystemModel country = new SystemModel();
				country.setId(countries.getIntcountryid());
				country.setName(countries.getStrcountryname());
				countrylist.add(country);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return countrylist;
	}
	
	public List<SystemModel> getStateListforaCountry(int countryid){
	
		List<SystemModel> statelist = new ArrayList<SystemModel>();
		try{
			
			
			List queryresult = executeHqlQuery("from Mstblstate where intcountryid.intcountryid = "+countryid);
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblstate states = (Mstblstate)i.next();
				SystemModel state = new SystemModel();
				state.setId(states.getIntstateid());
				state.setName(states.getStrstatename());
				statelist.add(state);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return statelist;
	}
	
	public List<SystemModel> getStateList(){
		
		List<SystemModel> statelist = new ArrayList<SystemModel>();
		try{
			
			
			List queryresult = executeHqlQuery("from Mstblstate");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblstate states = (Mstblstate)i.next();
				SystemModel state = new SystemModel();
				state.setId(states.getIntstateid());
				state.setName(states.getStrstatename());
				statelist.add(state);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return statelist;
	}
	
	public List<SystemModel> getCityListfromStateId(int stateid){
		
		List<SystemModel> citylist = new ArrayList<SystemModel>();
		try{
			
			
			List queryresult = executeHqlQuery("from Mstblcity where intstateid.intstateid = "+stateid);
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblcity cities = (Mstblcity)i.next();
				SystemModel city = new SystemModel();
				city.setId(cities.getIntcityid());
				city.setName(cities.getStrcityname());
				citylist.add(city);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return citylist;
	}
	
	public List<SystemModel> getCityList(){
		
		List<SystemModel> citylist = new ArrayList<SystemModel>();
		try{
			
			
			List queryresult = executeHqlQuery("from Mstblcity");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblcity cities = (Mstblcity)i.next();
				SystemModel city = new SystemModel();
				city.setId(cities.getIntcityid());
				city.setName(cities.getStrcityname());
				citylist.add(city);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return citylist;
	}
	
	public List<SystemModel> getInstitutionfromUniveristyId(int univeristyid){
		
		List<SystemModel> citylist = new ArrayList<SystemModel>();
		try{
			
			
			List queryresult = executeHqlQuery("from Mstblinstitution where intuniversityid.intuniversityid = "+univeristyid);
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblinstitution institutions = (Mstblinstitution)i.next();
				SystemModel institution = new SystemModel();
				institution.setId(institutions.getIntinstitutionid());
				institution.setName(institutions.getStrinstitutionname());
				citylist.add(institution);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return citylist;
	}
	
	public List<SystemModel> getCourseList(){
		
		List<SystemModel> Courselist = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstblcourse");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblcourse courses = (Mstblcourse)i.next();
				SystemModel course = new SystemModel();
				course.setId(courses.getIntcourseid());
				course.setName(courses.getStrcoursename());
				Courselist.add(course);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return Courselist;
	}
	
	public List<SystemModel> getLocalityListfromCityid(int cityid){
		
		List<SystemModel> localityList = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstbllocality where intcityid.intcityid = "+cityid);
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstbllocality localities = (Mstbllocality)i.next();
				SystemModel locality = new SystemModel();
				locality.setId(localities.getIntlocalityid());
				locality.setName(localities.getStrlocalityname());
				localityList.add(locality);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return localityList;
	}
	
	public List<SystemModel> getLocalityList(){
		
		List<SystemModel> localityList = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstbllocality");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstbllocality localities = (Mstbllocality)i.next();
				SystemModel locality = new SystemModel();
				locality.setId(localities.getIntlocalityid());
				locality.setName(localities.getStrlocalityname());
				localityList.add(locality);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return localityList;
	}
	
	public List<SystemModel> getMemberTypeList(){
		
		List<SystemModel> membertypelist = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstblmembertype");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblmembertype membertypes = (Mstblmembertype)i.next();
				SystemModel membertype = new SystemModel();
				membertype.setId(membertypes.getInttypeid());
				membertype.setName(membertypes.getStrtypename());
				membertypelist.add(membertype);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return membertypelist;
	}
	
	public List<SystemModel> getStudentTypeList(){
		
		List<SystemModel> studenttypelist = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstblstudytype");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblstudytype studytypes = (Mstblstudytype)i.next();
				SystemModel studytype = new SystemModel();
				studytype.setId(studytypes.getInttypeid());
				studytype.setName(studytypes.getStrtypename());
				studenttypelist.add(studytype);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return studenttypelist;
	} 
	
	public List<SystemModel> getInstituitonFromUniversity(int universityid){
		
		List<SystemModel> statelist = new ArrayList<SystemModel>();
		try{
			
			
			List queryresult = executeHqlQuery("from Mstblinstitution where intuniversityid.intuniversityid = "+universityid);
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblinstitution institution = (Mstblinstitution)i.next();
				SystemModel state = new SystemModel();
				state.setId(institution.getIntinstitutionid());
				state.setName(institution.getStrinstitutionname());
				statelist.add(state);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return statelist;
	}
	
	public List<SystemModel> getSubjectList(){
		
		List<SystemModel> Courselist = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstblsubject");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblsubject subjects = (Mstblsubject)i.next();
				SystemModel subject = new SystemModel();
				subject.setId(subjects.getIntsubjectid());
				subject.setName(subjects.getStrsubjectname());
				Courselist.add(subject);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return Courselist;
	}
	
	public List<SystemModel> getEditionList(){
		
		List<SystemModel> Courselist = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstbledition");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstbledition editions = (Mstbledition)i.next();
				SystemModel edition = new SystemModel();
				edition.setId(editions.getEditionid());
				edition.setName(editions.getEditionname());
				Courselist.add(edition);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return Courselist;
	}
	
	public List<SystemModel> getConditionList(){
		
		List<SystemModel> Courselist = new ArrayList<SystemModel>();
		try{
			
			List queryresult = executeHqlQuery("from Mstblcondition");
			for(Iterator i = queryresult.iterator(); i.hasNext();){
				Mstblcondition condtns = (Mstblcondition)i.next();
				SystemModel condt = new SystemModel();
				condt.setId(condtns.getIntconditionid());
				condt.setName(condtns.getStrconditionname());
				Courselist.add(condt);
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return Courselist;
	}
}

